package com.wolfking.converter.transform.extend;

import com.wolfking.converter.transform.AbstractExtendTransform;
import com.wolfking.converter.util.CaesarUtil;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

//给输入明文加密用的参数转换器
public class CaesarEncryptTransform extends AbstractExtendTransform<Object> {
    @Override
    public Object transform(Object value) throws Exception {
        if (Objects.isNull(value)) {
            return value;
        }
        if (value instanceof String && StringUtils.isBlank(value.toString())) {
            return value;
        }
        if (!CaesarUtil.isEncrypted(value.toString())) {
            return CaesarUtil.encode(value.toString());
        }
        return value;
    }
}
